import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

function _ (name) {
  return () => System.import(`@/pages/${name}.vue`)
}

var routes = [
  {
    path: '/',
    component: _('App/Index'),
    children: [
      {
        path: '/',
        name: 'dashboard',
        component: _('Dashboard/Index')
      }
    ]
  }
]

var router = new Router({
  mode: 'history',
  routes: routes,
  linkActiveClass: 'active',
  scrollBehavior (to, from, savedPosition) {
    document.getElementById('page-view').scrollTop = 0
    return { x: 0, y: 0 }
  }
})

router.beforeEach((to, from, next) => {
  console.log(to)
  next()
})

export default router
